import axiosInstance from '/@/request/axios.ts'
import { CommonPageParam } from '/@/type/CommonPageParam.ts'
import { PromiseAxiosRespData, PromiseAxiosRespPage } from '/@/type/CommonType.ts'
import { CommonVo } from '/@/type/CommonVo.ts'

export namespace SysPermissionApi {
  export const page = (params: CommonPageParam): PromiseAxiosRespPage<PermissionType> => {
    return axiosInstance({
      url: '/sysPermission/page',
      method: 'get',
      params,
    })
  }

  export const detail = (id: number): PromiseAxiosRespData<PermissionType> => {
    return axiosInstance({
      url: '/sysPermission/detail',
      method: 'get',
      params: { id },
    })
  }

  export const edit = (data: PermissionType): PromiseAxiosRespData => {
    return axiosInstance({
      url: '/sysPermission/edit',
      method: 'put',
      data,
    })
  }

  export const add = (data: PermissionType): PromiseAxiosRespData => {
    return axiosInstance({
      url: '/sysPermission/add',
      method: 'post',
      data,
    })
  }

  export const deleteBatch = (data: PermissionType[]): PromiseAxiosRespData => {
    return axiosInstance({
      url: '/sysPermission/delete',
      method: 'delete',
      data,
    })
  }

  export interface PermissionType extends CommonVo {
    id?: number // 主键
    name?: string // 权限名
    value?: string // 权限值;例如接口名称、权限代码等
    category?: string // 权限类型;可以按照api权限或者其他类型的权限进行分类。暂时没想好
    business?: string // 业务类型;按照业务类型进行分类，例如：角色管理、用户管理
    description?: string // 描述
  }
}
